﻿using System;
using AngryManagementMayhem.Controller.Player;
using AngryManagementMayhem.Controller.Player.Input;
using AngryManagementMayhem.GameCode.Screens.PlayScreen;
using Transformable_Engine_v2.Engine.Animation.PositionAnimation;
using Transformable_Engine_v2.Engine.GameObjects.Containers;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace AngryManagementMayhem.Content.Textures.Character
{
    public class TestCharacter : Player
    {
        public TestCharacter(TE_Vector2 position, InputManager inputKeys) : base(position, inputKeys)
        {
            TestCharacterSpriteSheet.LoadContent();
        }

        protected override void GetBody(Player.PlayerStateList state)
        {
            switch (state)
            {
                case PlayerStateList.Idle:
                    Body.Sprite = TestCharacterSpriteSheet.GetSprite(TestCharacterSpriteSheet.SpriteList.Idle);
                    break;
                case PlayerStateList.Jump:
                    Body.Sprite = TestCharacterSpriteSheet.GetSprite(TestCharacterSpriteSheet.SpriteList.Jump);
                    break;
                case PlayerStateList.Fall:
                    Body.Sprite = TestCharacterSpriteSheet.GetSprite(TestCharacterSpriteSheet.SpriteList.Fall);
                    break;
                case PlayerStateList.DoubleJump:
                    Body.Sprite = TestCharacterSpriteSheet.GetSprite(TestCharacterSpriteSheet.SpriteList.DoubleJump);
                    break;
                case PlayerStateList.Hurt:
                    Body.Sprite = TestCharacterSpriteSheet.GetSprite(TestCharacterSpriteSheet.SpriteList.Hurt);
                    break;
                case PlayerStateList.Dash:
                    Body.Sprite = TestCharacterSpriteSheet.GetSprite(TestCharacterSpriteSheet.SpriteList.Dash);
                    break;
                case PlayerStateList.Run:
                    Body.Sprite = TestCharacterSpriteSheet.GetSprite(TestCharacterSpriteSheet.SpriteList.Run);
                    break;
                case PlayerStateList.WallCling:
                    Body.Sprite = TestCharacterSpriteSheet.GetSprite(TestCharacterSpriteSheet.SpriteList.WallCling);
                    break;
                default:
                    throw new ArgumentOutOfRangeException("state");
            }

            Body.Origin = TE_Rectangle.Alignment.BottomMiddle;
        }

        protected override void GetChargeParticle(int level)
        {
            switch (level)
            {
                case 0:
                    ChargeParticle.Visible = false;
                    ChargeParticle.Sprite = TestCharacterSpriteSheet.GetSprite(TestCharacterSpriteSheet.SpriteList.ChargeLow);
                    break;
                case 1:
                    ChargeParticle.Visible = true;
                    break;
                case 2:
                    ChargeParticle.Sprite = TestCharacterSpriteSheet.GetSprite(TestCharacterSpriteSheet.SpriteList.ChargeMedium);
                    break;
                case 3:
                    ChargeParticle.Sprite = TestCharacterSpriteSheet.GetSprite(TestCharacterSpriteSheet.SpriteList.ChargeHigh);
                    break;
            }

            ChargeParticle.Origin = TE_Rectangle.Alignment.BottomMiddle;
        }

        protected override void ShootProjectile(int chargeLevel, TE_Vector2 positionGridBound, TE_Vector2 direction)
        {
            var projectile = new ImageContainer
            {
                Sprite = TestCharacterSpriteSheet.GetSprite(TestCharacterSpriteSheet.SpriteList.Particle),
                Origin = TE_Rectangle.Alignment.CenterMiddle,
                PositionGridBound = positionGridBound.Offset(direction.X * 2, -2.5f),
                Scale = new TE_Vector2(chargeLevel * 0.5f + 0.5f, chargeLevel * 0.5f + 0.5f),
            };

            projectile.AddAnimations(new PositionUniformLinearAnimation(0, direction * 21));

            PlayScreen.Map.ProjectileScreen.AddChildren(projectile);
            
        }
    }
}